<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    //冒泡排序
    // 就是一种算法，进行数组排序（从小到大或者从大到小）
    // 双层for循环
    function mp(arr) {
        console.log(arr)
            // 从大到小排序
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] < arr[i + 1]) {
                var tmp = arr[i]
                arr[i] = arr[i + 1]
                arr[i + 1] = tmp
            }
        }
        return arr
    }
    console.log(mp([1, 3, 7, 9, -2, 5, 8]))
</script>